home *** CD-ROM | disk | FTP | other *** search
- Path: damon.irf.uni.dortmund.de!broth
- From: rothert@damon.irf.uni-dortmund.de (Bernd Rothert)
- Newsgroups: comp.lang.c++
- Subject: Re: Watcom: corrupt this-pointer
- Date: Mon, 05 Feb 96 12:48:06 GMT
- Organization: Institute of Robotics Research
- Message-ID: <4f4uh6$o2m@damon.irf.uni-dortmund.de>
- References: <31108A0B.108DC964@sp.zrz.tu-berlin.de> <4eudvi$e84@gidora.kralizec.net.au>
- NNTP-Posting-Host: broth.irf
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- >Olaf Lenzmann <olafbaje@sp.zrz.tu-berlin.de> wrote:
- >>I have a really confusing problem with Watcom-C++ 10.0:
- <<...large memory model. When I create any of
- >>my objects dynamically, the constructor seems to use a
- >>corrput segment adress for the this-pointer. The offset
- >>is ok, but anyway it results in a zillion general protection
- >>faults...
-
- You might not see the proper member data if you debug your program with the
- Watcom-C++ 10.0a debugger. It has a serious bug which makes it display all
- member data as if the object were allocated in the DGROUP.
- Try the following example and set a breakpoint inside the ctor (line cout
- <<...):
-
- #include <iostream.h>
- class A {
- const char* name;
- public:
- A(const char* n) : name(n) {
- cout << "Created A(" << name << ")" << endl;
- }
- };
-
- int main()
- {
- A a("a on stack/DGROUP");
- A* pa = new A("pa on heap");
- return 0;
- }
-
- You can use an explicit cast to see the proper member data:
- "((A*)this)->name"
-
- This bug has been fixed in the 10.5 version - though this version still has
- problems with passing default arguments requiring temporary objects...
-
- Bernd
-